package com.wuze.cloud.controller;

import com.wuze.cloud.request.*;
import com.wuze.cloud.response.SysFolderResponse;
import com.wuze.cloud.response.SysShareFolderResponse;
import com.wuze.cloud.response.SysShareResponse;
import com.wuze.cloud.result.Result;
import com.wuze.cloud.service.SysShareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author wuze
 * @Date 2023/5/8 10:17
 * @ClassName: SysShareController
 * @Description: TODO
 */
@RestController
public class SysShareController {

    public static final String PREFIX_PATH = "/sys/share/";

    @Autowired
    private SysShareService shareService;

    @PostMapping(PREFIX_PATH+"findByPage/v1")
    public Result<SysShareResponse> findByPage(@RequestBody SysShareQuery query){
        return Result.success(shareService.findByPage(query));
    }

    @PostMapping(PREFIX_PATH+"getShareFolderById/v1")
    public Result<SysShareFolderResponse> getShareFolder(@RequestBody SysShareFolderQuery query){
        return Result.success(shareService.getShareFolder(query));
    }

    @PostMapping(PREFIX_PATH+"findShareByPage/v1")
    public Result<SysFolderResponse> findShareByPage(@Validated @RequestBody SysShareFolderQuery query){
        return Result.success(shareService.findShareByPage(query));
    }

    @PostMapping(PREFIX_PATH+"createShare/v1")
    public Result<Boolean> createShare(@Validated @RequestBody SysCreateShareQuery query){
        shareService.createShare(query);
        return Result.success(Boolean.TRUE);
    }

    @PostMapping(PREFIX_PATH+"updateShare/v1")
    public Result<Boolean> updateShare(@RequestBody SysUpdateShareQuery query){
        shareService.updateShare(query);
        return Result.success(Boolean.TRUE);
    }

    @PostMapping(PREFIX_PATH+"deleteShare/v1")
    public Result<Boolean> deleteShare(@RequestBody SysDeleteShareQuery query){
        shareService.deleteShare(query);
        return Result.success(Boolean.TRUE);
    }

    @PostMapping(PREFIX_PATH+"saveShare/v1")
    public Result<Boolean> saveShare(@RequestBody SysShareSaveQuery query){
        shareService.saveShare(query);
        return Result.success(Boolean.TRUE);
    }


}
